//
//  WDViewController.m
//  CategoryKit
//
//  Created by likuifeng on 11/02/2016.
//  Copyright (c) 2016 likuifeng. All rights reserved.
//

#import "WDViewController.h"
#import "FFUIFactoryViewController.h"
#import <FFPublicThird/Masonry.h>

@interface WDViewController ()

@property (nonatomic, strong) UIButton *uifactoryBtn;

@end

@implementation WDViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.

    self.title = @"Example";
    self.view.backgroundColor = [UIColor whiteColor];
    
    NSMutableArray *temp = [NSMutableArray array];
    [temp safeAddObject:@"11"];
    [temp safeAddObject:@"22"];
    
    NSLog(@"%@",temp);
    [self.view addSubview:self.uifactoryBtn];
    
    NSArray *btnArray = @[self.uifactoryBtn];
    for (int i = 0; i < btnArray.count; i++) {
        UIButton *currentBtn = [btnArray safeObjectAtIndex:i];
        UIButton *previousBtn = [btnArray safeObjectAtIndex:i-1];
        [currentBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(previousBtn ? previousBtn.mas_bottom : self.view).offset(previousBtn ? 50 : 100);
            make.centerX.equalTo(self.view);
            make.size.mas_equalTo(CGSizeMake(200, 50));
        }];
    }
}

- (void)buttonAction:(UIButton *)button{
    UIViewController *sampleViewController = nil;
    switch (button.tag) {
        case 1001:{
            sampleViewController = [[FFUIFactoryViewController alloc] init];
            break;
        }
        default:
            break;
    }
    sampleViewController.title = button.ff_normalTitle;
    [self.navigationController pushViewController:sampleViewController animated:YES];
}

- (UIButton *)generateButton{
    return [UIButton ff_buttonWithSize:CGSizeMake(200, 50) cornerRadius:5 font:[UIFont systemFontOfSize:15] normalColor:[UIColor whiteColor] selectedColor:[UIColor blackColor] disabledColor:nil normalBgColor:[UIColor blackColor] selectedBgColor:[UIColor whiteColor] disabledBgColor:nil];
}

- (UIButton *)uifactoryBtn{
    if (_uifactoryBtn == nil) {
        _uifactoryBtn = [self generateButton];
        _uifactoryBtn.tag = 1001;
        _uifactoryBtn.ff_normalTitle = @"FFUIFactory";
        [_uifactoryBtn ff_addTarget:self touchAction:@selector(buttonAction:)];
    }
    return _uifactoryBtn;
}

@end
